package com.wiim.nhapnhap;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;

import com.wiim.handler.BaseCmdHandler;
import com.wiim.interfaceapp.CommandAsyncTask;
import com.wiim.interfaceapp.IServiceCommandResult;


public class AppGlobal {
	public static AppGlobal g_AppMgr = null;
	public SCREEN_UI m_PrevScreenMode = SCREEN_UI.NONE;
	private static Fragment ac;
	public static enum SCREEN_UI {
		NONE, POPUP, LOGIN, REGISTER ,
	   LOADING, MAIN, HOME, Personal, Exchange, CALL1 , Setting, MORE_UI,VIEWIMAGE,SHAREFRIEND,EDITPROFILE,
	   TRANSACTION_HISTORY,GIFT,
	   
	   APP_EXIT
	}

	public static AppGlobal getInstance(Fragment _Activity) {
		if (g_AppMgr == null) {
			// getSystemService
			g_AppMgr = new AppGlobal();
		}

		// set current activity
//		g_AppMgr.setActivity(_Activity);
		ac=_Activity;
		return g_AppMgr;
	}

	public static AppGlobal getInstance() {

		if (g_AppMgr == null) {
			// getSystemService
			g_AppMgr = new AppGlobal();
//			g_AppMgr.initApp();
		}

		return g_AppMgr;
	}
	public void startServiceCmd(int command, BaseCmdHandler handler,
			Bundle cmdData,boolean showProgress) {
		startServiceCmd(command, ac, handler, cmdData,showProgress);
	}

	public void startServiceCmd(int command, Object ac2,
			BaseCmdHandler handler, Bundle cmdData,boolean showProgress) {
		try {
			CommandAsyncTask task = new CommandAsyncTask(ac2, handler,command, cmdData,showProgress);
			task.execute();
		} catch (Exception ex) {
			Log.v("HAI", ex.getMessage());
		}
	}
	
	public void startServiceCmd(int command, IServiceCommandResult ac2,
			BaseCmdHandler handler, Bundle cmdData,boolean showProgress) {
		try {
			CommandAsyncTask task = new CommandAsyncTask(ac2, handler,command, cmdData,showProgress);
			task.execute();
		} catch (Exception ex) {
			Log.v("HAI", ex.getMessage());
		}
	}

//	public void startServiceCmdSilent(int command, IServiceCommandResult host,
//			BaseCmdHandler handler, Bundle cmdData) {
//		try {
//			CommandAsyncTask task = new CommandAsyncTask(host, handler,
//					command, cmdData, false);
//			task.execute();
//		} catch (Exception ex) {
//		}
//	}

}